package Smt.Util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//读取配置文件的工具类
public class ConfigManager {

	private static ConfigManager configManager;
	private static Properties properties;

	//读取配置文件
	private ConfigManager() {
		String conString = "database.properties";
		properties = new Properties();
		InputStream in = ConfigManager.class.getClassLoader().getResourceAsStream(conString);
		try {
			properties.load(in);
			in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	//确保单例
	public static ConfigManager getInstance() {

		if (configManager == null)
			configManager = new ConfigManager();
		return configManager;
	}

	//通过key获取响应value
	public String getString(String key) {
		return properties.getProperty(key);
	}
}
